<html>
<head>
	<meta charset="UTF-8">
	<title>定时调度配置详情</title>
	<link  id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/css/esaas-easyui-view.css" rel="stylesheet" type="text/css"/>
	<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
	<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.easyui.ext.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
	<script src="../../ffres/dict/all.js" type="text/javascript"></script>
	<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<body class="easyui-layout">

<form id="ff" method="post">
	<div class="esaas-info-title">定时调度配置信息</div>
	<table class="esaas-info-view-table">
		<tr>
			<td width="15%" align="right">定时作业编号：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="jobCode" data-options="required:true, disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">定时作业描述：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="jobDesc" data-options="required:false, disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">执行节点标识：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="agentId" data-options="required:true, disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right"><span id="subsCodeLabel">所属系统：</span></td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="subsCode" id="subsCode" data-options="required:false,disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">作业类类型：</td>
			<td width="35%"><select class="easyui-combobox"
									id="jobClassType" name="jobClassType"
									style="width: 100%; height: 25px;"
									data-options="required:true, disabled: true,editable:false,valueField:'enname',textField:'cnname',data:JOB_CLASS_TYPE, onSelect: onChangeJobType">
			</select></td>
			<td width="15%" align="right">作业实现类：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="jobClass" data-options="required:true, disabled: true"
								   style="width: 100%; height: 25px;"></input></td>

		</tr>
		<tr>
			<td width="15%" align="right">作业类方法：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="jobMethod" data-options="required:true, disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right"><span id="serviceVersionLabel">服务版本：</span></td>
			<td width="35%"><input class="easyui-textbox" type="text" id="serviceVersion"
								   name="serviceVersion" data-options="required:true, disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right"><span id="serviceGroupLabel">服务组别：</span></td>
			<td width="35%"><input class="easyui-textbox" type="text" id="serviceGroup"
								   name="serviceGroup" data-options="required:false, disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="18%" align="right"><span id="serviceTimeoutLabel">服务超时时间(毫秒)：</span></td>
			<td width="35%"><input class="easyui-textbox" type="text" id="serviceTimeout"
								   name="serviceTimeout" data-options="required:false, disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">失败重试次数：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="againTime" data-options="required:true, disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">重试间隔秒数：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="retrySecond" data-options="required:false, disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">作业状态：</td>
			<td width="35%"><select class="easyui-combobox"
									id="jobState" name="jobState"
									style="width: 100%; height: 25px;"
									data-options="required:false,disabled: true,editable:false,valueField:'enname',textField:'cnname',data:JOB_STATE">
			</select></td>
			<td width="15%" align="right">耗时（秒）：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="costTime" data-options="required:false,disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">上一次执行时间：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="lastExecuteTime" data-options="required:false,disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">下一次执行时间：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="nextExecuteTime" data-options="required:false,disabled: true"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">执行周期：</td>
			<td width="35%"><input class="easyui-textbox"
								   id="cronExpression" name="cronExpression" data-options="required:true"
								   style="width: 100%; height: 25px;"></input>
				<select class="easyui-combobox" type="text" id="select_cron" style="width: 20%; height: 25px;"
						data-options="required:false,editable:false,disabled: true,valueField:'value',textField:'text',onSelect:selectCron">
					<option value="day">每天</option>
					<option value="nDay">N天</option>
					<option value="hours">每小时</option>
					<option value="nHours">N小时</option>
					<option value="nMinutes">N分钟</option>
					<option value="week">每星期</option>
					<option value="month">每月</option>
				</select>
				<select class="easyui-combobox" id="week" style="width: 20%; height: 25px;"
						data-options="required:false,editable:false,disabled: true,valueField:'value',textField:'text'">
					<option value="1">周一</option>
					<option value="2">周二</option>
					<option value="3">周三</option>
					<option value="4">周四</option>
					<option value="5">周五</option>
					<option value="6">周六</option>
					<option value="7">周日</option>
				</select>
				<select class="easyui-combobox" id="day" style="width: 25%; height: 25px;" buttonText="天"
						data-options="required:false,editable:true,disabled: true,valueField:'value',textField:'text'">
				</select>
				<select class="easyui-combobox" id="hours" style="width: 25%; height: 25px;" buttonText="时"
						data-options="required:false,editable:true,disabled: true,valueField:'value',textField:'text'">
				</select>
				<select class="easyui-combobox" id="minutes" style="width: 25%; height: 25px;" buttonText="分"
						data-options="required:false,editable:true,disabled: true,valueField:'value',textField:'text'">
				</select>
			</td>
		</tr>
		<tr>
			<td width="15%" align="right">备注：</td>
			<td width="85%" colspan="3"><input class="easyui-textbox" type="text"
			    name="remark" data-options="required:false, disabled: true, multiline: true"
			    style="width: 100%; height: 50px;"></input></td>
		</tr>
	</table>
</form>
<div class="esaas-info-buttons">
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeForm()" style="width:90px">&nbsp;关&nbsp;闭&nbsp;</a>
</div>
</div>
<script>
	$(function() {
		addTitle("查看")
		cronShowInit();
		var jobCode = $.getUrlParam('jobCode');
		$.restfulGet('../../api/s/srvs/cron/conf/' + jobCode,null,function(data){
			$('#ff').form('load', {
				jobCode : data.rows.jobCode,
				jobDesc : data.rows.jobDesc,
				jobClassType : data.rows.jobClassType,
				jobClass : data.rows.jobClass,
				jobMethod : data.rows.jobMethod,
				serviceVersion : data.rows.serviceVersion,
				serviceGroup : data.rows.serviceGroup,
				serviceTimeout : data.rows.serviceTimeout,
				cronExpression : data.rows.cronExpression,
				againTime : data.rows.againTime,
				retrySecond : data.rows.retrySecond,
				agentId : data.rows.agentId,
				subsCode:data.rows.subsCode,
				remark : data.rows.remark,
				jobState : data.rows.jobState,
				lastExecuteTime : data.rows.lastExecuteTime,
				nextExecuteTime : data.rows.nextExecuteTime,
				costTime : data.rows.costTime
			});
			showByCron(data.rows.cronExpression);
			onChangeJobType({enname: data.rows.jobClassType});
		});
	});

	function onChangeJobType(data){
		if(data && (data.enname == 'hsf' || data.enname == 'dubbo')) {
			$("#serviceVersionLabel").show();
			$("#serviceVersion").next().show();
			$("#serviceGroupLabel").show();
			$("#serviceGroup").next().show();
			$("#serviceTimeoutLabel").show();
			$("#serviceTimeout").next().show();
		} else {
			$("#serviceVersionLabel").hide();
			$("#serviceVersion").next().hide();
			$("#serviceGroupLabel").hide();
			$("#serviceGroup").next().hide();
			$("#serviceTimeoutLabel").hide();
			$("#serviceTimeout").next().hide();

			$("#serviceVersion").textbox("setValue", '');
			$("#serviceGroup").textbox("setValue", '');
			$("#serviceTimeout").textbox("setValue", '');
		}
	}

	function showByCron(cron){
		var cronList=cron.trim().split(" ");
		if(cronList[5]=="?"){
			if(cronList[2]=="*"&&cronList[3]=="*"&&cronList[4]=="*"){
				if(cronList[1].indexOf("*/")==-1){
					$("#minutes").combobox("setValue",cronList[1]);
					$("#select_cron").combobox("setValue","hours")
				}else{
					cronList[1]=cronList[1].replace("*/","");
					$("#minutes").combobox("setValue",cronList[1]);
					$("#select_cron").combobox("setValue","nMinutes")
				}
			}else if(cronList[3]=="*"&&cronList[4]=="*"){
				if(cronList[2].indexOf("*/")==-1){
					$("#hours").combobox("setValue",cronList[2]);
					$("#minutes").combobox("setValue",cronList[1]);
					$("#select_cron").combobox("setValue","day")
				}else{
					cronList[2]=cronList[2].replace("*/","");
					$("#hours").combobox("setValue",cronList[2]);
					$("#minutes").combobox("setValue",cronList[1]);
					$("#select_cron").combobox("setValue","nHours")
				}
			}else if(cronList[4]=="*"){
				if(cronList[3].indexOf("*/")==-1){
					$("#day").combobox("setValue",cronList[3]);
					$("#hours").combobox("setValue",cronList[2]);
					$("#minutes").combobox("setValue",cronList[1]);
					$("#select_cron").combobox("setValue","month")
				}else{
					cronList[3]=cronList[3].replace("*/","");
					$("#day").combobox("setValue",cronList[3]);
					$("#hours").combobox("setValue",cronList[2]);
					$("#minutes").combobox("setValue",cronList[1]);
					$("#select_cron").combobox("setValue","nDay")
				}
			}
		}else{
			$("#week").combobox("setValue",cronList[5]);
			$("#hours").combobox("setValue",cronList[2]);
			$("#minutes").combobox("setValue",cronList[1]);
			$("#select_cron").combobox("setValue","week")
		}
		selectCron();
	}

	function cronShowInit(){
		$("#cronExpression").next().hide();
		onChangeJobType(null);
		var hoursData = [{}];
		for (var i = 0; i < 24; i++) {
			hoursData.push({ text: i, value: i });
		}
		$("#hours").combobox("loadData", hoursData);
		var minutesData = [{}];
		for (var i = 0; i < 60; i++) {
			minutesData.push({ text: i, value: i });
		}
		$("#minutes").combobox("loadData", minutesData);
		var dayData = [{}];
		for (var i = 1; i < 32; i++) {
			dayData.push({ text: i, value: i });
		}
		$("#day").combobox("loadData", dayData);
		$("#week").next().hide();
		$("#day").next().hide();
	}

	function selectCron(){
		var selectValue=$("#select_cron").combobox("getValue");
		if(selectValue=="day" ||selectValue=="nHours"){
			$("#week").next().hide();
			$("#day").next().hide();
			$("#hours").next().show();
			$("#minutes").next().show();
		}else if(selectValue=="month"||selectValue=="nDay"){
			$("#week").next().hide();
			$("#day").next().show();
			$("#hours").next().show();
			$("#minutes").next().show();
		}else if(selectValue=="hours"||selectValue=="nMinutes"){
			$("#week").next().hide();
			$("#day").next().hide();
			$("#hours").next().hide();
			$("#minutes").next().show();
		}else if(selectValue=="week"){
			$("#week").next().show();
			$("#day").next().hide();
			$("#hours").next().show();
			$("#minutes").next().show();
		}
	}

	function closeForm(){
		window.parent.JLEUtil.closewin();
	}
</script>
</body>
</html>